//
//  SectionHeaderView.m
//  BaiTuan
//
//  Created by 看着太阳吃烧饼 on 15/12/23.
//  Copyright © 2015年 YR. All rights reserved.
//

#import "SectionHeaderView.h"

@implementation SectionHeaderView
{
    UILabel *_titleLabel;
    UILabel *_scoreLabel;
    UILabel *_commentsCountLabel;
    UILabel *_distanceLable;
    UILabel *_placeLabel;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubviews];
    }
    return self;
}


- (void)createSubviews
{
    UIView *headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, 70)];
    headerView.backgroundColor = [UIColor whiteColor];
    [self addSubview:headerView];
    
    _titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, kScreenWidth - 20, 30)];
    _titleLabel.font = [UIFont systemFontOfSize:16];
    _titleLabel.textColor = [UIColor blackColor];
    [headerView addSubview:_titleLabel];
    
    _scoreLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, 50, 60, 10)];
    _scoreLabel.textColor = [UIColor orangeColor];
    _scoreLabel.font = [UIFont systemFontOfSize:12];
    [headerView addSubview:_scoreLabel];
    
    _commentsCountLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 50, 10)];
    _commentsCountLabel.left = _scoreLabel.right + 20;
    _commentsCountLabel.top = _scoreLabel.top;
    _commentsCountLabel.textColor = [UIColor colorWithWhite:0.8 alpha:1];
    _commentsCountLabel.font = [UIFont systemFontOfSize:12];
    [headerView addSubview:_commentsCountLabel];
    
    _distanceLable = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 50, 10)];
    _distanceLable.right = kScreenWidth - 10;
    _distanceLable.top = _commentsCountLabel.top;
    _distanceLable.textColor = [UIColor colorWithWhite:0.8 alpha:1];
    _distanceLable.font = [UIFont systemFontOfSize:12];
    [headerView addSubview:_distanceLable];
    
    _placeLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 50, 10)];
    _placeLabel.right = _distanceLable.left - 20;
    _placeLabel.top = _distanceLable.top;
    _placeLabel.textColor = [UIColor colorWithWhite:0.8 alpha:1];
    _placeLabel.font = [UIFont systemFontOfSize:12];
    [headerView addSubview:_placeLabel];
}

- (void)setShopsModel:(ShopsModel *)shopsModel
{
    if (_shopsModel != shopsModel) {
        _shopsModel = shopsModel;

        _titleLabel.text = shopsModel.shop_name;
        _scoreLabel.text = [NSString stringWithFormat:@"团单数:%@", shopsModel.deal_num];
        _distanceLable.text = [NSString stringWithFormat:@"%.1lfkm", [shopsModel.distance doubleValue] / 1000.0];
        
    }
}

@end
